<?php

class Model_Keywords {

    protected $md5;
    protected $original_text;
    protected $anchor_text;
    protected $normalized_text;
    protected $category_id;

    public function __construct(array $options = null) {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value) {
        $method = 'set' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        }
        $this->$method($value);
    }

    public function __get($name) {
        $method = 'get' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        } return $this->$method();
    }

    public function setOptions(array $options) {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
    }

    public function setMd5($value) {
        $this->md5 = $value;
    }

    public function getMd5() {
        return $this->md5;
    }

    public function setOriginal_text($value) {
        $this->original_text = $value;
    }

    public function getOriginal_text() {
        return $this->original_text;
    }

    public function setAnchor_text($value) {
        $this->anchor_text = $value;
    }

    public function getAnchor_text() {
        return $this->anchor_text;
    }

    public function setNormalized_text($value) {
        $this->normalized_text = $value;
    }

    public function getNormalized_text() {
        return $this->normalized_text;
    }

    public function setCategory_id($value) {
        $this->category_id = $value;
    }

    public function getCategory_id() {
        return $this->category_id;
    }

    public function toArray() {
        return get_object_vars($this);
    }

}

